package com.example.feign.controller;

import com.example.feign.rpc.UserRPC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class TestController {

    @Autowired
    private UserRPC userRPC;

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/getuserRPC")
    public String getUserRPC() {
        return userRPC.getuser();
    }

    @RequestMapping(value = "/getuserREST",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getUserRest(){
        String result = restTemplate.getForObject("http://user-service//getuser?name=rest-9000",String.class);
        return result;
    }
}
